<%@ page language="java" import="java.util.*,cn.ac.cintcm.dataconverge.util.Constants,com.hs.core.utils.*" pageEncoding="UTF-8"%>
<%@ page import ="cn.ac.cintcm.dataconverge.researchsubject.domain.*" %> 
<%@ page import ="cn.ac.cintcm.dataconverge.researcher.domain.*" %> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List orgList = (ArrayList)request.getAttribute("orgList");
String idStr = (String)request.getAttribute("idStr");
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title><%=Constants.APP_TITLE %>--指定评审专家</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache"> 
	<script language="javascript" type="text/javascript" src="<%=path %>/js/My97DatePicker/WdatePicker.js"></script>
	<script language="javascript" src="<%=path %>/index/Scripts/script.js"></script>
	<script language="javascript" src="<%=path %>/js/common.js"></script>
	<link href="<%=path %>/index/Themes/com/style.css" type="text/css" rel="stylesheet"></link>
	 <script src='<%=basePath%>dwr/engine.js'></script>
     <script src='<%=basePath%>dwr/util.js'></script> 
     <script src='<%=basePath%>dwr/interface/subject.js'></script> 
     
     <script type="text/javascript">
     function getUserInfo(){
         var org = document.getElementById("org").value;
         var expertName = document.getElementById("expertName").value;
         subject.getExpertInfo(org,expertName,getExpertCallBack); 
     } 
     function getExpertCallBack(dataStr){  
       if(''!= dataStr){ 
          dwr.util.addOptions("selectedExpert", eval(dataStr),'id','name');  
       } 
     
     }
     function orgChange(){
     	dwr.util.removeAllOptions("selectedExpert");
     	getUserInfo(); 
     }
     function selectExpert() { 
	    var listAllRoles = document.getElementById("selectedExpert"); 
	    var listSelectedRoles = document.getElementById("allSelected"); 
	    for (var i = 0; i < listAllRoles.length; i ++) { 
	        if (listAllRoles.options[i].selected) { 
	            var ignore = false; 
	            for (var j = 0; j < listSelectedRoles.options.length; j ++) { 
	                if (listSelectedRoles.options[j].text == listAllRoles.options[i].text) { 
	                    ignore = true; 
	                    break; 
	                } 
	            } 
	            if (!ignore) { 
	                var newOption = new Option(listAllRoles.options[i].text, listAllRoles.options[i].value); 
	                listSelectedRoles.options.add(newOption); 
	            } 
	        } 
	    } 
	} 

	function removeSelected() { 
	    var listSelectedRoles = document.getElementById("allSelected"); 
	    var array1 = new Array(); 
	    for (var i = listSelectedRoles.options.length - 1; i >= 0; i --) { 
	        if (listSelectedRoles.options[i].selected) 
	            listSelectedRoles.options.remove(i); 
	    } 
	} 
	
	function submitData(){ 
	   var idStr = '<%=idStr%>';
	   var selectedArr = document.getElementById("allSelected");
	   var expertStr = '';
	   for(var i = 0;i<selectedArr.length;i++){ 
	      expertStr+=selectedArr[i].value+",";
	   } 
	   if('' == expertStr){
	         alert("请选择专家");
	         return;
	         }
	   var syntype = dwr.util.getValue("syntype");
	   if('' == syntype){
	   		 alert("请填写评审类别");
	   		 return;
	   		 } 
	   subject.addSynData(idStr,syntype,expertStr,submitCallback); 
	}
	function submitCallback(message){ 
	  alert(message); 
	  window.close();
	  if(window.opener.pageForm)
			window.opener.pageForm.submit();
	}
     </script>
  </head> 
  <body class="idt_body" scroll="yes">
    <table cellpadding="0" cellspacing="0" width="100%" height="100%" id="Table8">
        <tr>
            <td valign="top" height="100%">
                <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0" id="Table11">
                    <tr>
                        <td class="idt_main_m">
                            <!------------------ 标题栏 ------------------>
                            <!--- 标题 ---->
                            <table class="idt_tle_mg" cellspacing="0" cellpadding="0" width="100%">
                                <tr onclick="javascript:OnShow(tdForm,imgForm6);">
                                    <td class="idt_tle_i">
                                        <img id="imgForm6" src="<%=path %>/index/Themes/com/idt_tle_o.gif"></td>
                                    <td class="idt_tle_f1">
                                        专家选择</td>
                                </tr>
                            </table>
                            <!--- 内容 --->
                            <div id="tdForm">
                                <table border="0" cellpadding="0" cellspacing="1" width="100%" class="com_fieldset_tab">
                                    <tr>
                                        <td style="width:50%" align="center">
                                            <table border="0" cellpadding="2" cellspacing="0"> 
                                                <tr>
                                                <td class="fim_l" width="10%">&nbsp;&nbsp;单位:
                                                </td>
                                                <td class="fim_r" width="90%" colspan="3">
                                                        <select name="org" id="org" style="width:100%" onchange="orgChange();">
                                                        <option value="0">-----请选择-----</option>
                                                       <%if(orgList.size()>0){
                                                    	   for(int i =0;i<orgList.size();i++){
                                                    		   Organization org = (Organization)orgList.get(i);
                                                    	       out.print("<option value=\"");
                                                    	       out.print(org.getId());
                                                    	       out.print("\">");
                                                    	       out.print(org.getName());
                                                    	       out.print("</option>");
                                                    	       
                                                    	   }} %>  
                                                       </select>
                                                       &nbsp;&nbsp; 
                                                    </td>
                                                      
                                                </tr>
                                                <tr>
                                                
                                                     <td class="fim_l" width="10%">&nbsp;&nbsp;专家姓名：
                                                </td>
                                                 <td class="fim_r" colspan="3"> 
                                                 <input type="text" name="expertName" style="width:100%" onpropertychange="orgChange();" id="expertName" class="com_textbox" value=""/>
                                                </td>
                                                </tr>
                                                <tr>
                                                    <td class="fim_r" align="center" colspan="4">
                                                        <select size="25" id="selectedExpert" style="width:100%; line-height: 35px; padding: 5px 5px;" multiple>
                                                            
                                                        </select>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td style="width:2%">
                                            <input type="submit"   value=">>"  style="font-family: SimSun;" onclick="return selectExpert();" /> 
                							<br /> 
                							<input type="submit"   value="&lt;&lt;"     style="font-family: SimSun;" onclick="return removeSelected();" /> 
                                        </td>
                                       <td style="width:50%" align="center">
                                            <table border="0" cellpadding="2" cellspacing="0"> 
                                                <tr>
                                                <td class="fim_l"  >&nbsp;&nbsp;已选择专家
                                                </td> 
                                                </tr>
                                                <tr>
                                                    <td class="fim_r" align="center" colspan="2">
                                                        <select size="25" id="allSelected" style="width:100%; line-height: 35px; padding: 5px 5px;">
                                                             
                                                        </select>
                                                    </td>
                                                </tr>
                                                <tr>
                                                <td class="fim_l" width="10%">&nbsp;&nbsp;评审类别
                                                </td>
                                                <td class="fim_r"  > 
                                                <input type="text" name="syntype"  class="com_textbox" value=""/>
                                                </td> 
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                                <table cellspacing="0" cellpadding="0" width="100%" class="idt_bottom_mg" border="0">
                                    <tr>
                                        <td align="right">
                                            <input type="button" value="保存" name="B3" class="com_btn2" id="Button1" onclick="javascript:submitData();">
                                            <input type="button" value="关闭" name="B4" class="com_btn2" id="Button2" onclick="javascript:window.close();">
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</body>
</html>
<script type="text/javascript">
<!--
getUserInfo();
//-->
</script>
